var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("AssetsManager"),
    s = cc._decorator,
    l = s.ccclass,
    c = s.property,
    d = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.role_head = null),
                (t.choose_node = null),
                (t.role_type_node = null),
                (t.unlock_node = null),
                (t.taste_node = null),
                (t.role_index = 0),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.showRoleInfo = function (e, t) {
                (this.role_index = t),
                    (this.role_head.spriteFrame = r.default.getInstance().getHeroHeadFrame(e.C_ID)),
                    (this.role_type_node.children[0].active = 0 == e.C_type),
                    (this.role_type_node.children[1].active = 1 == e.C_type);
                var o = i.GlobalParams.playerSkinInfo.value;
                (this.unlock_node.active = -1 == o.have.hero.indexOf(t)),
                    (this.node.zIndex = this.unlock_node.active ? 2 : 1),
                    o.have.taste_card > 0 && this.unlock_node.active
                        ? ((this.unlock_node.active = !1), (this.taste_node.active = !0))
                        : (this.taste_node.active = !1),
                    (this.choose_node.active = t == o.use[0]),
                    this.node.on("click", this.chooseThisRole, this);
            }),
            (t.prototype.addEvent = function () {
                this.attachEvent(a.default.SEND_CHOOSE_ROLE_INDEX_INFO, this.chooseRoleInfo, this),
                    this.attachEvent(a.default.SEND_UPDATE_CHOOSE_HERO_LIST, this.updateThisRole, this);
            }),
            (t.prototype.updateThisRole = function () {
                var e = i.GlobalParams.playerSkinInfo.value;
                (this.unlock_node.active = -1 == e.have.hero.indexOf(this.role_index)),
                    e.have.taste_card > 0 && this.unlock_node.active
                        ? ((this.unlock_node.active = !1), (this.taste_node.active = !0))
                        : (this.taste_node.active = !1),
                    (this.node.zIndex = this.unlock_node.active ? 2 : 1);
            }),
            (t.prototype.chooseRoleInfo = function (e, t) {
                this.choose_node.active = t == this.role_index;
            }),
            (t.prototype.chooseThisRole = function () {
                this.emitEvent(a.default.SEND_CHOOSE_ROLE_INDEX_INFO, this.role_index);
            }),
            __decorate([c(cc.Sprite)], t.prototype, "role_head", void 0),
            __decorate([c(cc.Node)], t.prototype, "choose_node", void 0),
            __decorate([c(cc.Node)], t.prototype, "role_type_node", void 0),
            __decorate([c(cc.Node)], t.prototype, "unlock_node", void 0),
            __decorate([c(cc.Node)], t.prototype, "taste_node", void 0),
            __decorate([l], t)
        );
    })(n.default);
o.default = d;
